<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <link rel="stylesheet" href="css/vue-bootstrap.css" type="text/css"/>
</head>
<body>
<div id="cx-app" class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-sm-6">
                            <a class="mb-sm btn btn-primary">新增</a>
                        </div>
                        <div class="col-sm-6">
                            <a class="mb-sm btn btn-primary pull-right" v-on:click="getToken">注销</a>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    {{tokenInfo.access_token}}<br/>
                    {{tokenInfo.token_type}}<br/>
                    {{tokenInfo.refresh_token}}<br/>
                    {{tokenInfo.expires_in}}<br/>
                    {{tokenInfo.scope}}<br/>
                </div>
            </div>
        </div>
    </div>

</div>
<script src="js/vue-bootstrap.js" type="application/javascript"></script>
<script>
    var vm = new Vue({
        el:'#cx-app',
        data:{
            tokenInfo:{}
        },
        methods:{
            getUser:function () {
                console.log($.cookie('XSRF-TOKEN'));

                //var vue = this;
                /*$.ajax({
                    url:"/uc/userApi/list",
                    type:'GET',
                    data:{},
                    success:function(result){
                        console.log(result);
                        if (result){
                            vue.tableInfo.dataRow = result;
                        }
                    }
                });*/
            },

            getToken: function () {
                var params = {
                    scope: 'app',
                    username: '1hxl@163.com',
                    password: 'pwd',
                    grant_type: 'password'
                };
                var _$this = this;
                $.ajax({
                    url: 'http://localhost:5555/uaa/oauth/token',
                    datatype: 'json',
                    type: 'post',
                    headers: {'Authorization': 'Basic dnMtYW5ndWxhcjpzZWNyZXQ='},
                    async: false,
                    data: params,
                    success: function (data) {
                        _$this.tokenInfo=data;
                        console.log(data);
                    },
                    error: function () {

                    }
                });
            }
        },
        mounted:function () {
            this.getUser();
        }
    });
</script>
</body>
</html>